using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using ToolsLayer;
using BusinessEntity;
using Webcar.BLL;

namespace Webcar.SysManage
{
    public partial class InfoReadPanel : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        public string GetClientID()
        {
            return this.Panel1.ClientID;
        }
        public void InitPanel(string msg_xh)
        {
            string sql = "select a.man_code,c.name,isnull(b.infoid,'0') is_read " +
            " from dbo.SEND_MSG_LOG a left join InfoList b" +
            " on a.msg_xh = b.infoid  and" +
            " a.man_code=b.username and "+
            " b.tablename='{1}'"+
            " join v_all_users c" +
            " on a.man_code=c.account" +
            " where a.msg_xh='{0}'";
            InfoChecker ic = new InfoChecker();
            sql = string.Format(sql, msg_xh, ic.GetTableAlias(InfoCheckType.Gs));
            DataSet ds = DB.ExecuteDataset(sql);
            ds.Tables[0].PrimaryKey = new DataColumn[] { ds.Tables[0].Columns["man_code"] };
            this.CheckBoxList1.DataTextField = "oper_name";
            this.CheckBoxList1.DataValueField = "man_code";
            this.CheckBoxList1.DataSource = ds;
            this.CheckBoxList1.DataBind();
            foreach (ListItem li in this.CheckBoxList1.Items)
            {
                DataRow row = ds.Tables[0].Rows.Find(new object[] { li.Value });
                if (row != null)
                {
                    if(row["is_read"].ToString()!="0")
                        li.Selected = true;
                }
            }
        }
    }
}